package Balance;

/**
 * @Author: 0162977
 * @Date: 2020/12/13 20:02
 */
public class ShareSpaceAndFun {


    public static int myPort = 4060 ;
    public static int portA = 4030 ;
    public static int portB = 4031 ;

    public static int a = 1;
    public static int b = 1;
    public static int aPoint = 1;
    public static int bPoint = 1;

    public static void updatePoint(int port,int p){
        if (port == portA){
            aPoint = p;
        }else if (port == portB){
            bPoint = p;
        }
    }
    public static int chooseRoot(){
        if (a/b > aPoint/bPoint){
            b=b+1;
            if (b>10000){b=1;a=1;}
            return portB;
        }else {
            a=a+1;
            if (a>10000){b=1;a=1;}
            return portA;
        }
    }

}
